<?php


class LivePackageMapping extends CActiveRecord
{
	
	public static function model($Vgmajjibziuy=__CLASS__)
	{
		return parent::model($Vgmajjibziuy);
	}

	
	public function tableName()
	{
		return 'live_package_mapping';
	}

	
	public function rules()
	{
		
		
		return array(
			array('live_package_id, live_channel_id', 'required'),
			array('status, live_package_id, live_channel_id', 'numerical', 'integerOnly'=>true),
			array('create_date', 'safe'),
			
			
			array('id, create_date, status, live_package_id, live_channel_id', 'safe', 'on'=>'search'),
		);
	}

	
	public function relations()
	{
		
		
		return array(
			'liveChannel' => array(self::BELONGS_TO, 'LiveChannel', 'live_channel_id'),
			'livePackage' => array(self::BELONGS_TO, 'LivePackage', 'live_package_id'),
		);
	}

	
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'create_date' => 'Create Date',
			'status' => 'Status',
			'live_package_id' => 'Live Package',
			'live_channel_id' => 'Live Channel',
		);
	}

	
	public function search()
	{
		
		

		$V0v5vsnfxezw=new CDbCriteria;

		$V0v5vsnfxezw->compare('id',$this->id);
		$V0v5vsnfxezw->compare('create_date',$this->create_date,true);
		$V0v5vsnfxezw->compare('status',$this->status);
		$V0v5vsnfxezw->compare('live_package_id',$this->live_package_id);
		$V0v5vsnfxezw->compare('live_channel_id',$this->live_channel_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$V0v5vsnfxezw,
		));
	}
	
	public function getLivePackageName() {
		$Vlbektgrrjr0 = LivePackage::model()->findByPk($this->live_package_id);
		if($Vlbektgrrjr0 == NULL) {
			return 'UNKNOWN';
		}
		else {
			return $Vlbektgrrjr0->display_name;
		}
	}

	public function getLiveChannelName() {
		$V3mcuyb10a4j = LiveChannel::model()->findByPk($this->live_channel_id);
		if($V3mcuyb10a4j == NULL) {
			return 'UNKNOWN';
		}
		else {
			return $V3mcuyb10a4j->display_name;
		}
	}
	
	public function getPackageMapping($Vmhbyr2g4l1c) {
		$V0v5vsnfxezw=new CDbCriteria;
		$V0v5vsnfxezw->compare('live_package_id',$Vmhbyr2g4l1c);
		$V0v5vsnfxezw->compare('status',1);
		return new CActiveDataProvider($this, array(
				'criteria'=>$V0v5vsnfxezw,
		));
	}
}